<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "psacar_memberinfo.php" ?>
<?php include "psacar_userinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$psacar_member_add = new cpsacar_member_add();
$Page =& $psacar_member_add;

// Page init
$psacar_member_add->Page_Init();

// Page main
$psacar_member_add->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

// Create page object
var psacar_member_add = new ew_Page("psacar_member_add");

// page properties
psacar_member_add.PageID = "add"; // page ID
psacar_member_add.FormID = "fpsacar_memberadd"; // form ID
var EW_PAGE_ID = psacar_member_add.PageID; // for backward compatibility

// extend page with ValidateForm function
psacar_member_add.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_first_name"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($psacar_member->first_name->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_last_name"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($psacar_member->last_name->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_occupation_id"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($psacar_member->occupation_id->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_password"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($psacar_member->password->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_type_id"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($psacar_member->type_id->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_created_date"];
		if (elm && !ew_CheckDate(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($psacar_member->created_date->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_modified_date"];
		if (elm && !ew_CheckDate(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($psacar_member->modified_date->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_number_vehicle"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($psacar_member->number_vehicle->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}

// extend page with Form_CustomValidate function
psacar_member_add.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
psacar_member_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
psacar_member_add.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-cold-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Add") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $psacar_member->TableCaption() ?><br><br>
<a href="<?php echo $psacar_member->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$psacar_member_add->ShowMessage();
?>
<form name="fpsacar_memberadd" id="fpsacar_memberadd" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return psacar_member_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="psacar_member">
<input type="hidden" name="a_add" id="a_add" value="A">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($psacar_member->type_id->Visible) { // type_id ?>
	<tr<?php echo $psacar_member->type_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->type_id->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $psacar_member->type_id->CellAttributes() ?>><span id="el_type_id">
<select id="x_type_id" name="x_type_id" title="<?php echo $psacar_member->type_id->FldTitle() ?>"<?php echo $psacar_member->type_id->EditAttributes() ?>>
<?php
if (is_array($psacar_member->type_id->EditValue)) {
	$arwrk = $psacar_member->type_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_member->type_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $psacar_member->type_id->CustomMsg ?></td>
	</tr>
<?php } ?> 
        <tr>
            <td colspan="2">
                <strong>Account</strong>
            </td>
        </tr>        
<?php if ($psacar_member->name->Visible) { // name ?>
	<tr<?php echo $psacar_member->name->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->name->FldCaption() ?></td>
		<td<?php echo $psacar_member->name->CellAttributes() ?>><span id="el_name">
<input type="text" name="x_name" id="x_name" title="<?php echo $psacar_member->name->FldTitle() ?>" size="30" maxlength="100" value="<?php echo $psacar_member->name->EditValue ?>"<?php echo $psacar_member->name->EditAttributes() ?>>
</span><?php echo $psacar_member->name->CustomMsg ?></td>
	</tr>
<?php } ?>   
<?php if ($psacar_member->password->Visible) { // password ?>
	<tr<?php echo $psacar_member->password->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->password->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $psacar_member->password->CellAttributes() ?>><span id="el_password">
<input type="password" name="x_password" id="x_password" title="<?php echo $psacar_member->password->FldTitle() ?>" size="30" maxlength="18"<?php echo $psacar_member->password->EditAttributes() ?>>
</span><?php echo $psacar_member->password->CustomMsg ?></td>
	</tr>
<?php } ?>
        <tr>
            <td colspan="2">
                <strong>Company</strong>
            </td>
        </tr>
<?php if ($psacar_member->company->Visible) { // company ?>
	<tr<?php echo $psacar_member->company->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->company->FldCaption() ?></td>
		<td<?php echo $psacar_member->company->CellAttributes() ?>><span id="el_company">
<input type="text" name="x_company" id="x_company" title="<?php echo $psacar_member->company->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $psacar_member->company->EditValue ?>"<?php echo $psacar_member->company->EditAttributes() ?>>
</span><?php echo $psacar_member->company->CustomMsg ?></td>
	</tr>
<?php } ?>  
<?php if ($psacar_member->company_phone_1->Visible) { // company_phone_1 ?>
	<tr<?php echo $psacar_member->company_phone_1->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->company_phone_1->FldCaption() ?></td>
		<td<?php echo $psacar_member->company_phone_1->CellAttributes() ?>><span id="el_company_phone_1">
<input type="text" name="x_company_phone_1" id="x_company_phone_1" title="<?php echo $psacar_member->company_phone_1->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $psacar_member->company_phone_1->EditValue ?>"<?php echo $psacar_member->company_phone_1->EditAttributes() ?>>
</span><?php echo $psacar_member->company_phone_1->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($psacar_member->company_phone_2->Visible) { // company_phone_2 ?>
	<tr<?php echo $psacar_member->company_phone_2->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->company_phone_2->FldCaption() ?></td>
		<td<?php echo $psacar_member->company_phone_2->CellAttributes() ?>><span id="el_company_phone_2">
<input type="text" name="x_company_phone_2" id="x_company_phone_2" title="<?php echo $psacar_member->company_phone_2->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $psacar_member->company_phone_2->EditValue ?>"<?php echo $psacar_member->company_phone_2->EditAttributes() ?>>
</span><?php echo $psacar_member->company_phone_2->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($psacar_member->website->Visible) { // website ?>
	<tr<?php echo $psacar_member->website->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->website->FldCaption() ?></td>
		<td<?php echo $psacar_member->website->CellAttributes() ?>><span id="el_website">
<input type="text" name="x_website" id="x_website" title="<?php echo $psacar_member->website->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $psacar_member->website->EditValue ?>"<?php echo $psacar_member->website->EditAttributes() ?>>
</span><?php echo $psacar_member->website->CustomMsg ?></td>
	</tr>
<?php } ?>  
<?php 
if ($psacar_member->car_type->Visible) 
{ 
    // car_type 
?>
    <tr<?php echo $psacar_member->car_type->RowAttributes ?>>
        <td class="ewTableHeader"><?php echo $psacar_member->car_type->FldCaption() ?></td>
        <td<?php echo $psacar_member->car_type->CellAttributes() ?>><span id="el_car_type">
            <div id="tp_x_car_type" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME; ?>"><input type="checkbox" name="x_car_type[]" id="x_car_type[]" title="<?php echo $psacar_member->car_type->FldTitle() ?>" value="{value}"<?php echo $psacar_member->car_type->EditAttributes() ?>>
            </div>
            <div id="dsl_x_car_type" repeatcolumn="5">
<?php
            $arwrk = $psacar_member->car_type->EditValue;
            if (is_array($arwrk)) {
                $armultiwrk= explode(",", strval($psacar_member->car_type->CurrentValue));
                $rowswrk = count($arwrk);
                $emptywrk = TRUE;
                for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
                    $selwrk = "";
                    for ($ari = 0; $ari < count($armultiwrk); $ari++) {
                        if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
                            $selwrk = " checked=\"checked\"";
                            if ($selwrk <> "") $emptywrk = FALSE;
                            break;
                        }
                    }

                    // Note: No spacing within the LABEL tag
?>
<?php 
                    echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1);
?>
                <label>
                    <input type="checkbox" name="x_car_type[]" id="x_car_type[]" title="<?php echo $psacar_member->car_type->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $psacar_member->car_type->EditAttributes() ?>>
<?php 
                    echo $arwrk[$rowcntwrk][1] ;
?>
                </label>
<?php 
                echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2);
?>
<?php
                }
            }
?>
            </div>
            </span>
<?php 
                echo $psacar_member->car_type->CustomMsg 
?>
        </td>
    </tr>
<?php 
}
?>        
<?php if ($psacar_member->address->Visible) { // address ?>
	<tr<?php echo $psacar_member->address->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->address->FldCaption() ?></td>
		<td<?php echo $psacar_member->address->CellAttributes() ?>><span id="el_address">
<textarea name="x_address" id="x_address" title="<?php echo $psacar_member->address->FldTitle() ?>" cols="35" rows="4"<?php echo $psacar_member->address->EditAttributes() ?>><?php echo $psacar_member->address->EditValue ?></textarea>
</span><?php echo $psacar_member->address->CustomMsg ?></td>
	</tr>
<?php } ?>        
        <tr>
            <td colspan="2">
                <strong>Contact</strong>
            </td>
        </tr>         
<?php 
/*
if ($psacar_member->location_id->Visible) { // location_id ?>
	<tr<?php echo $psacar_member->location_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->location_id->FldCaption() ?></td>
		<td<?php echo $psacar_member->location_id->CellAttributes() ?>><span id="el_location_id">
<select id="x_location_id" name="x_location_id" title="<?php echo $psacar_member->location_id->FldTitle() ?>"<?php echo $psacar_member->location_id->EditAttributes() ?>>
<?php
if (is_array($psacar_member->location_id->EditValue)) {
	$arwrk = $psacar_member->location_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_member->location_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $psacar_member->location_id->CustomMsg ?></td>
	</tr>
<?php } 
*/
?>
<?php if ($psacar_member->last_name->Visible) { // last_name ?>
	<tr<?php echo $psacar_member->last_name->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->last_name->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $psacar_member->last_name->CellAttributes() ?>><span id="el_last_name">
<input type="text" name="x_last_name" id="x_last_name" title="<?php echo $psacar_member->last_name->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $psacar_member->last_name->EditValue ?>"<?php echo $psacar_member->last_name->EditAttributes() ?>>
</span><?php echo $psacar_member->last_name->CustomMsg ?></td>
	</tr>
<?php } ?>        
<?php if ($psacar_member->first_name->Visible) { // first_name ?>
	<tr<?php echo $psacar_member->first_name->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->first_name->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $psacar_member->first_name->CellAttributes() ?>><span id="el_first_name">
<input type="text" name="x_first_name" id="x_first_name" title="<?php echo $psacar_member->first_name->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $psacar_member->first_name->EditValue ?>"<?php echo $psacar_member->first_name->EditAttributes() ?>>
</span><?php echo $psacar_member->first_name->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php 
if ($psacar_member->gender->Visible) { // gender ?>
	<tr<?php echo $psacar_member->gender->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->gender->FldCaption() ?></td>
		<td<?php echo $psacar_member->gender->CellAttributes() ?>><span id="el_gender">
<select id="x_gender" name="x_gender" title="<?php echo $psacar_member->gender->FldTitle() ?>"<?php echo $psacar_member->gender->EditAttributes() ?>>
<?php
if (is_array($psacar_member->gender->EditValue)) {
	$arwrk = $psacar_member->gender->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_member->gender->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $psacar_member->gender->CustomMsg ?></td>
	</tr>
<?php } 
?>             
<?php if ($psacar_member->contact_phone_1->Visible) { // contact_phone_1 ?>
	<tr<?php echo $psacar_member->contact_phone_1->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->contact_phone_1->FldCaption() ?></td>
		<td<?php echo $psacar_member->contact_phone_1->CellAttributes() ?>><span id="el_contact_phone_1">
<input type="text" name="x_contact_phone_1" id="x_contact_phone_1" title="<?php echo $psacar_member->contact_phone_1->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $psacar_member->contact_phone_1->EditValue ?>"<?php echo $psacar_member->contact_phone_1->EditAttributes() ?>>
</span><?php echo $psacar_member->contact_phone_1->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($psacar_member->contact_phone_2->Visible) { // contact_phone_2 ?>
	<tr<?php echo $psacar_member->contact_phone_2->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->contact_phone_2->FldCaption() ?></td>
		<td<?php echo $psacar_member->contact_phone_2->CellAttributes() ?>><span id="el_contact_phone_2">
<input type="text" name="x_contact_phone_2" id="x_contact_phone_2" title="<?php echo $psacar_member->contact_phone_2->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $psacar_member->contact_phone_2->EditValue ?>"<?php echo $psacar_member->contact_phone_2->EditAttributes() ?>>
</span><?php echo $psacar_member->contact_phone_2->CustomMsg ?></td>
	</tr>
<?php } ?>    
<?php if ($psacar_member->zemail->Visible) { // email ?>
	<tr<?php echo $psacar_member->zemail->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->zemail->FldCaption() ?></td>
		<td<?php echo $psacar_member->zemail->CellAttributes() ?>><span id="el_zemail">
<input type="text" name="x_zemail" id="x_zemail" title="<?php echo $psacar_member->zemail->FldTitle() ?>" size="30" maxlength="45" value="<?php echo $psacar_member->zemail->EditValue ?>"<?php echo $psacar_member->zemail->EditAttributes() ?>>
</span><?php echo $psacar_member->zemail->CustomMsg ?></td>
	</tr>
<?php } ?>        
<?php if ($psacar_member->industry_id->Visible) { // industry_id ?>
	<tr<?php echo $psacar_member->industry_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->industry_id->FldCaption() ?></td>
		<td<?php echo $psacar_member->industry_id->CellAttributes() ?>><span id="el_industry_id">
<select id="x_industry_id" name="x_industry_id" title="<?php echo $psacar_member->industry_id->FldTitle() ?>"<?php echo $psacar_member->industry_id->EditAttributes() ?>>
<?php
if (is_array($psacar_member->industry_id->EditValue)) {
	$arwrk = $psacar_member->industry_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_member->industry_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $psacar_member->industry_id->CustomMsg ?></td>
	</tr>
<?php } ?> 
<?php if ($psacar_member->occupation_id->Visible) { // occupation_id ?>
	<tr<?php echo $psacar_member->occupation_id->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->occupation_id->FldCaption() ?></td>
		<td<?php echo $psacar_member->occupation_id->CellAttributes() ?>><span id="el_occupation_id">
<select id="x_occupation_id" name="x_occupation_id" title="<?php echo $psacar_member->occupation_id->FldTitle() ?>"<?php echo $psacar_member->occupation_id->EditAttributes() ?>>
<?php
if (is_array($psacar_member->occupation_id->EditValue)) {
	$arwrk = $psacar_member->occupation_id->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_member->occupation_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $psacar_member->occupation_id->CustomMsg ?></td>
	</tr>
<?php } ?>          
<?php 
/*
if ($psacar_member->service->Visible) { // service ?>
	<tr<?php echo $psacar_member->service->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->service->FldCaption() ?></td>
		<td<?php echo $psacar_member->service->CellAttributes() ?>><span id="el_service">
<div id="tp_x_service" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME; ?>"><input type="checkbox" name="x_service[]" id="x_service[]" title="<?php echo $psacar_member->service->FldTitle() ?>" value="{value}"<?php echo $psacar_member->service->EditAttributes() ?>></div>
<div id="dsl_x_service" repeatcolumn="5">
<?php
$arwrk = $psacar_member->service->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($psacar_member->service->CurrentValue));
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		for ($ari = 0; $ari < count($armultiwrk); $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked=\"checked\"";
				if ($selwrk <> "") $emptywrk = FALSE;
				break;
			}
		}

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="checkbox" name="x_service[]" id="x_service[]" title="<?php echo $psacar_member->service->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $psacar_member->service->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span><?php echo $psacar_member->service->CustomMsg ?></td>
	</tr>
<?php } 
*/
?>        
<?php 
/*
if ($psacar_member->description->Visible) { // description ?>
	<tr<?php echo $psacar_member->description->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->description->FldCaption() ?></td>
		<td<?php echo $psacar_member->description->CellAttributes() ?>><span id="el_description">
<textarea name="x_description" id="x_description" title="<?php echo $psacar_member->description->FldTitle() ?>" cols="35" rows="4"<?php echo $psacar_member->description->EditAttributes() ?>><?php echo $psacar_member->description->EditValue ?></textarea>
</span><?php echo $psacar_member->description->CustomMsg ?></td>
	</tr>
<?php } 
*/
?>
<?php 
/*
if ($psacar_member->created_date->Visible) { // created_date ?>
	<tr<?php echo $psacar_member->created_date->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->created_date->FldCaption() ?></td>
		<td<?php echo $psacar_member->created_date->CellAttributes() ?>><span id="el_created_date">
<input type="text" name="x_created_date" id="x_created_date" title="<?php echo $psacar_member->created_date->FldTitle() ?>" value="<?php echo $psacar_member->created_date->EditValue ?>"<?php echo $psacar_member->created_date->EditAttributes() ?>>
&nbsp;<img src="images/calendar.png" id="cal_x_created_date" name="cal_x_created_date" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField: "x_created_date", // input field id
	ifFormat: "%Y/%m/%d", // date format
	button: "cal_x_created_date" // button id
});
</script>
</span><?php echo $psacar_member->created_date->CustomMsg ?></td>
	</tr>
<?php } 
*/
?>
<?php 
/*
if ($psacar_member->modified_date->Visible) { // modified_date ?>
	<tr<?php echo $psacar_member->modified_date->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->modified_date->FldCaption() ?></td>
		<td<?php echo $psacar_member->modified_date->CellAttributes() ?>><span id="el_modified_date">
<input type="text" name="x_modified_date" id="x_modified_date" title="<?php echo $psacar_member->modified_date->FldTitle() ?>" value="<?php echo $psacar_member->modified_date->EditValue ?>"<?php echo $psacar_member->modified_date->EditAttributes() ?>>
&nbsp;<img src="images/calendar.png" id="cal_x_modified_date" name="cal_x_modified_date" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField: "x_modified_date", // input field id
	ifFormat: "%Y/%m/%d", // date format
	button: "cal_x_modified_date" // button id
});
</script>
</span><?php echo $psacar_member->modified_date->CustomMsg ?></td>
	</tr>
<?php } 
*/
?>
<?php if ($psacar_member->number_vehicle->Visible) { // car_type ?>
	<tr<?php echo $psacar_member->number_vehicle->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->number_vehicle->FldCaption() ?></td>
		<td<?php echo $psacar_member->number_vehicle->CellAttributes() ?>><span id="el_number_vehicle">
<select id="x_number_vehicle" name="x_number_vehicle" title="<?php echo $psacar_member->number_vehicle->FldTitle() ?>"<?php echo $psacar_member->number_vehicle->EditAttributes() ?>>
<?php
if (is_array($psacar_member->number_vehicle->EditValue)) {
	$arwrk = $psacar_member->number_vehicle->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($psacar_member->number_vehicle->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $psacar_member->number_vehicle->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($psacar_member->is_active->Visible) { // is_active ?>
	<tr<?php echo $psacar_member->is_active->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $psacar_member->is_active->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $psacar_member->is_active->CellAttributes() ?>><span id="el_is_active">
<div id="tp_x_is_active" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME; ?>"><input type="checkbox" name="x_is_active[]" id="x_is_active[]" title="<?php echo $psacar_member->is_active->FldTitle() ?>" value="{value}"<?php echo $psacar_member->is_active->EditAttributes() ?>></div>
<div id="dsl_x_is_active" repeatcolumn="5">
<?php
$arwrk = $psacar_member->is_active->EditValue;
if (is_array($arwrk)) {
	$armultiwrk= explode(",", strval($psacar_member->is_active->CurrentValue));
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = "";
		for ($ari = 0; $ari < count($armultiwrk); $ari++) {
			if (strval($arwrk[$rowcntwrk][0]) == trim(strval($armultiwrk[$ari]))) {
				$selwrk = " checked=\"checked\"";
				if ($selwrk <> "") $emptywrk = FALSE;
				break;
			}
		}

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="checkbox" name="x_is_active[]" id="x_is_active[]" title="<?php echo $psacar_member->is_active->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $psacar_member->is_active->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span><?php echo $psacar_member->is_active->CustomMsg ?></td>
	</tr>
<?php } ?>        
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("AddBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php
$psacar_member_add->Page_Terminate();
?>
<?php

//
// Page class
//
class cpsacar_member_add {

	// Page ID
	var $PageID = 'add';

	// Table name
	var $TableName = 'psacar_member';

	// Page object name
	var $PageObjName = 'psacar_member_add';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $psacar_member;
		if ($psacar_member->UseTokenInUrl) $PageUrl .= "t=" . $psacar_member->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $psacar_member;
		if ($psacar_member->UseTokenInUrl) {
			if ($objForm)
				return ($psacar_member->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($psacar_member->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function cpsacar_member_add() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (psacar_member)
		$GLOBALS["psacar_member"] = new cpsacar_member();

		// Table object (psacar_user)
		$GLOBALS['psacar_user'] = new cpsacar_user();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'add', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'psacar_member', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $psacar_member;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Create form object
		$objForm = new cFormObj();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $sDbMasterFilter = "";
	var $sDbDetailFilter = "";
	var $lPriv = 0;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $psacar_member;

		// Load key values from QueryString
		$bCopy = TRUE;
		if (@$_GET["id"] != "") {
		  $psacar_member->id->setQueryStringValue($_GET["id"]);
		} else {
		  $bCopy = FALSE;
		}

		// Process form if post back
		if (@$_POST["a_add"] <> "") {
		   $psacar_member->CurrentAction = $_POST["a_add"]; // Get form action
		  $this->LoadFormValues(); // Load form values

			// Validate form
			if (!$this->ValidateForm()) {
				$psacar_member->CurrentAction = "I"; // Form error, reset action
				$this->setMessage($gsFormError);
			}
		} else { // Not post back
		  if ($bCopy) {
		    $psacar_member->CurrentAction = "C"; // Copy record
		  } else {
		    $psacar_member->CurrentAction = "I"; // Display blank record
		    $this->LoadDefaultValues(); // Load default values
		  }
		}

		// Perform action based on action code
		switch ($psacar_member->CurrentAction) {
		  case "I": // Blank record, no action required
				break;
		  case "C": // Copy an existing record
		   if (!$this->LoadRow()) { // Load record based on key
		      $this->setMessage($Language->Phrase("NoRecord")); // No record found
		      $this->Page_Terminate("psacar_memberlist.php"); // No matching record, return to list
		    }
				break;
		  case "A": // ' Add new record
				$psacar_member->SendEmail = TRUE; // Send email on add success
		    if ($this->AddRow()) { // Add successful
		      $this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
					$sReturnUrl = $psacar_member->getReturnUrl();
					$this->Page_Terminate($sReturnUrl); // Clean up and return
		    } else {
		      $this->RestoreFormValues(); // Add failed, restore form values
		    }
		}

		// Render row based on row type
		$psacar_member->RowType = EW_ROWTYPE_ADD;  // Render add type

		// Render row
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $psacar_member;

		// Get upload data
	}

	// Load default values
	function LoadDefaultValues() {
		global $psacar_member;
		$psacar_member->is_active->CurrentValue = 0;
	}

	// Load form values
	function LoadFormValues() {

            // Load from form
            global $objForm, $psacar_member;
            $psacar_member->location_id->setFormValue($objForm->GetValue("x_location_id"));
            $psacar_member->first_name->setFormValue($objForm->GetValue("x_first_name"));
            $psacar_member->last_name->setFormValue($objForm->GetValue("x_last_name"));
            $psacar_member->industry_id->setFormValue($objForm->GetValue("x_industry_id"));
            $psacar_member->company->setFormValue($objForm->GetValue("x_company"));
            $psacar_member->company_phone_1->setFormValue($objForm->GetValue("x_company_phone_1"));
            $psacar_member->company_phone_2->setFormValue($objForm->GetValue("x_company_phone_2"));
            $psacar_member->name->setFormValue($objForm->GetValue("x_name"));
            $psacar_member->gender->setFormValue($objForm->GetValue("x_gender"));
            $psacar_member->occupation_id->setFormValue($objForm->GetValue("x_occupation_id"));
            $psacar_member->contact_phone_1->setFormValue($objForm->GetValue("x_contact_phone_1"));
            $psacar_member->contact_phone_2->setFormValue($objForm->GetValue("x_contact_phone_2"));
            $psacar_member->address->setFormValue($objForm->GetValue("x_address"));
            $psacar_member->zemail->setFormValue($objForm->GetValue("x_zemail"));
            $psacar_member->website->setFormValue($objForm->GetValue("x_website"));
            $psacar_member->password->setFormValue($objForm->GetValue("x_password"));
            $psacar_member->type_id->setFormValue($objForm->GetValue("x_type_id"));
            $psacar_member->service->setFormValue($objForm->GetValue("x_service"));
            $psacar_member->description->setFormValue($objForm->GetValue("x_description"));
            $psacar_member->is_active->setFormValue($objForm->GetValue("x_is_active"));
            $psacar_member->created_date->setFormValue($objForm->GetValue("x_created_date"));
            $psacar_member->created_date->CurrentValue = ew_UnFormatDateTime($psacar_member->created_date->CurrentValue, 5);
            $psacar_member->modified_date->setFormValue($objForm->GetValue("x_modified_date"));
            $psacar_member->modified_date->CurrentValue = ew_UnFormatDateTime($psacar_member->modified_date->CurrentValue, 5);
            $psacar_member->number_vehicle->setFormValue($objForm->GetValue("x_number_vehicle"));
            $psacar_member->car_type->setFormValue($objForm->GetValue("x_car_type"));
            $psacar_member->code->setFormValue($objForm->GetValue("x_code"));
            $psacar_member->id->setFormValue($objForm->GetValue("x_id"));
	}

	// Restore form values
	function RestoreFormValues() {
            global $objForm, $psacar_member;
            $psacar_member->id->CurrentValue = $psacar_member->id->FormValue;
            $psacar_member->location_id->CurrentValue = $psacar_member->location_id->FormValue;
            $psacar_member->first_name->CurrentValue = $psacar_member->first_name->FormValue;
            $psacar_member->last_name->CurrentValue = $psacar_member->last_name->FormValue;
            $psacar_member->industry_id->CurrentValue = $psacar_member->industry_id->FormValue;
            $psacar_member->company->CurrentValue = $psacar_member->company->FormValue;
            $psacar_member->company_phone_1->CurrentValue = $psacar_member->company_phone_1->FormValue;
            $psacar_member->company_phone_2->CurrentValue = $psacar_member->company_phone_2->FormValue;
            $psacar_member->name->CurrentValue = $psacar_member->name->FormValue;
            $psacar_member->gender->CurrentValue = $psacar_member->gender->FormValue;
            $psacar_member->occupation_id->CurrentValue = $psacar_member->occupation_id->FormValue;
            $psacar_member->contact_phone_1->CurrentValue = $psacar_member->contact_phone_1->FormValue;
            $psacar_member->contact_phone_2->CurrentValue = $psacar_member->contact_phone_2->FormValue;
            $psacar_member->address->CurrentValue = $psacar_member->address->FormValue;
            $psacar_member->zemail->CurrentValue = $psacar_member->zemail->FormValue;
            $psacar_member->website->CurrentValue = $psacar_member->website->FormValue;
            $psacar_member->password->CurrentValue = $psacar_member->password->FormValue;
            $psacar_member->type_id->CurrentValue = $psacar_member->type_id->FormValue;
            $psacar_member->service->CurrentValue = $psacar_member->service->FormValue;
            $psacar_member->description->CurrentValue = $psacar_member->description->FormValue;
            $psacar_member->is_active->CurrentValue = $psacar_member->is_active->FormValue;
            $psacar_member->created_date->CurrentValue = $psacar_member->created_date->FormValue;
            $psacar_member->created_date->CurrentValue = ew_UnFormatDateTime($psacar_member->created_date->CurrentValue, 5);
            $psacar_member->modified_date->CurrentValue = $psacar_member->modified_date->FormValue;
            $psacar_member->modified_date->CurrentValue = ew_UnFormatDateTime($psacar_member->modified_date->CurrentValue, 5);
            $psacar_member->number_vehicle->CurrentValue = $psacar_member->number_vehicle->FormValue;
            $psacar_member->car_type->CurrentValue = $psacar_member->car_type->FormValue;
            $psacar_member->code->CurrentValue = $psacar_member->code->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $psacar_member;
		$sFilter = $psacar_member->KeyFilter();

		// Call Row Selecting event
		$psacar_member->Row_Selecting($sFilter);

		// Load SQL based on filter
		$psacar_member->CurrentFilter = $sFilter;
		$sSql = $psacar_member->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$psacar_member->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
            global $conn, $psacar_member;
            $psacar_member->id->setDbValue($rs->fields('id'));
            $psacar_member->location_id->setDbValue($rs->fields('location_id'));
            $psacar_member->first_name->setDbValue($rs->fields('first_name'));
            $psacar_member->last_name->setDbValue($rs->fields('last_name'));
            $psacar_member->industry_id->setDbValue($rs->fields('industry_id'));
            $psacar_member->company->setDbValue($rs->fields('company'));
            $psacar_member->company_phone_1->setDbValue($rs->fields('company_phone_1'));
            $psacar_member->company_phone_2->setDbValue($rs->fields('company_phone_2'));
            $psacar_member->name->setDbValue($rs->fields('name'));
            $psacar_member->gender->setDbValue($rs->fields('gender'));
            $psacar_member->occupation_id->setDbValue($rs->fields('occupation_id'));
            $psacar_member->contact_phone_1->setDbValue($rs->fields('contact_phone_1'));
            $psacar_member->contact_phone_2->setDbValue($rs->fields('contact_phone_2'));
            $psacar_member->address->setDbValue($rs->fields('address'));
            $psacar_member->zemail->setDbValue($rs->fields('email'));
            $psacar_member->website->setDbValue($rs->fields('website'));
            $psacar_member->password->setDbValue($rs->fields('password'));
            $psacar_member->type_id->setDbValue($rs->fields('type_id'));
            $psacar_member->service->setDbValue($rs->fields('service'));
            $psacar_member->description->setDbValue($rs->fields('description'));
            $psacar_member->photo->setDbValue($rs->fields('photo'));
            $psacar_member->is_active->setDbValue($rs->fields('is_active'));
            $psacar_member->created_date->setDbValue($rs->fields('created_date'));
            $psacar_member->modified_date->setDbValue($rs->fields('modified_date'));
            $psacar_member->number_vehicle->setDbValue($rs->fields('number_vehicle'));
            $psacar_member->car_type->setDbValue($rs->fields('car_type'));
            $psacar_member->code->setDbValue($rs->fields('code'));
	}

	// Render row values based on field settings
	function RenderRow() {
            global $conn, $Security, $Language, $psacar_member;

            // Initialize URLs
            // Call Row_Rendering event

            $psacar_member->Row_Rendering();

            // Common render codes for all row types
            // location_id

            $psacar_member->location_id->CellCssStyle = ""; $psacar_member->location_id->CellCssClass = "";
            $psacar_member->location_id->CellAttrs = array(); $psacar_member->location_id->ViewAttrs = array(); $psacar_member->location_id->EditAttrs = array();

            // first_name
            $psacar_member->first_name->CellCssStyle = ""; $psacar_member->first_name->CellCssClass = "";
            $psacar_member->first_name->CellAttrs = array(); $psacar_member->first_name->ViewAttrs = array(); $psacar_member->first_name->EditAttrs = array();

            // last_name
            $psacar_member->last_name->CellCssStyle = ""; $psacar_member->last_name->CellCssClass = "";
            $psacar_member->last_name->CellAttrs = array(); $psacar_member->last_name->ViewAttrs = array(); $psacar_member->last_name->EditAttrs = array();

            // industry_id
            $psacar_member->industry_id->CellCssStyle = ""; $psacar_member->industry_id->CellCssClass = "";
            $psacar_member->industry_id->CellAttrs = array(); $psacar_member->industry_id->ViewAttrs = array(); $psacar_member->industry_id->EditAttrs = array();

            // company
            $psacar_member->company->CellCssStyle = ""; $psacar_member->company->CellCssClass = "";
            $psacar_member->company->CellAttrs = array(); $psacar_member->company->ViewAttrs = array(); $psacar_member->company->EditAttrs = array();

            // company_phone_1
            $psacar_member->company_phone_1->CellCssStyle = ""; $psacar_member->company_phone_1->CellCssClass = "";
            $psacar_member->company_phone_1->CellAttrs = array(); $psacar_member->company_phone_1->ViewAttrs = array(); $psacar_member->company_phone_1->EditAttrs = array();

            // company_phone_2
            $psacar_member->company_phone_2->CellCssStyle = ""; $psacar_member->company_phone_2->CellCssClass = "";
            $psacar_member->company_phone_2->CellAttrs = array(); $psacar_member->company_phone_2->ViewAttrs = array(); $psacar_member->company_phone_2->EditAttrs = array();

            // name
            $psacar_member->name->CellCssStyle = ""; $psacar_member->name->CellCssClass = "";
            $psacar_member->name->CellAttrs = array(); $psacar_member->name->ViewAttrs = array(); $psacar_member->name->EditAttrs = array();

            // gender
            $psacar_member->gender->CellCssStyle = ""; $psacar_member->gender->CellCssClass = "";
            $psacar_member->gender->CellAttrs = array(); $psacar_member->gender->ViewAttrs = array(); $psacar_member->gender->EditAttrs = array();

            // occupation_id
            $psacar_member->occupation_id->CellCssStyle = ""; $psacar_member->occupation_id->CellCssClass = "";
            $psacar_member->occupation_id->CellAttrs = array(); $psacar_member->occupation_id->ViewAttrs = array(); $psacar_member->occupation_id->EditAttrs = array();

            // contact_phone_1
            $psacar_member->contact_phone_1->CellCssStyle = ""; $psacar_member->contact_phone_1->CellCssClass = "";
            $psacar_member->contact_phone_1->CellAttrs = array(); $psacar_member->contact_phone_1->ViewAttrs = array(); $psacar_member->contact_phone_1->EditAttrs = array();

            // contact_phone_2
            $psacar_member->contact_phone_2->CellCssStyle = ""; $psacar_member->contact_phone_2->CellCssClass = "";
            $psacar_member->contact_phone_2->CellAttrs = array(); $psacar_member->contact_phone_2->ViewAttrs = array(); $psacar_member->contact_phone_2->EditAttrs = array();

            // address
            $psacar_member->address->CellCssStyle = ""; $psacar_member->address->CellCssClass = "";
            $psacar_member->address->CellAttrs = array(); $psacar_member->address->ViewAttrs = array(); $psacar_member->address->EditAttrs = array();

            // email
            $psacar_member->zemail->CellCssStyle = ""; $psacar_member->zemail->CellCssClass = "";
            $psacar_member->zemail->CellAttrs = array(); $psacar_member->zemail->ViewAttrs = array(); $psacar_member->zemail->EditAttrs = array();

            // website
            $psacar_member->website->CellCssStyle = ""; $psacar_member->website->CellCssClass = "";
            $psacar_member->website->CellAttrs = array(); $psacar_member->website->ViewAttrs = array(); $psacar_member->website->EditAttrs = array();

            // password
            $psacar_member->password->CellCssStyle = ""; $psacar_member->password->CellCssClass = "";
            $psacar_member->password->CellAttrs = array(); $psacar_member->password->ViewAttrs = array(); $psacar_member->password->EditAttrs = array();

            // type_id
            $psacar_member->type_id->CellCssStyle = ""; $psacar_member->type_id->CellCssClass = "";
            $psacar_member->type_id->CellAttrs = array(); $psacar_member->type_id->ViewAttrs = array(); $psacar_member->type_id->EditAttrs = array();

            // service
            $psacar_member->service->CellCssStyle = ""; $psacar_member->service->CellCssClass = "";
            $psacar_member->service->CellAttrs = array(); $psacar_member->service->ViewAttrs = array(); $psacar_member->service->EditAttrs = array();

            // description
            $psacar_member->description->CellCssStyle = ""; $psacar_member->description->CellCssClass = "";
            $psacar_member->description->CellAttrs = array(); $psacar_member->description->ViewAttrs = array(); $psacar_member->description->EditAttrs = array();

            // is_active
            $psacar_member->is_active->CellCssStyle = ""; $psacar_member->is_active->CellCssClass = "";
            $psacar_member->is_active->CellAttrs = array(); $psacar_member->is_active->ViewAttrs = array(); $psacar_member->is_active->EditAttrs = array();

            // created_date
            $psacar_member->created_date->CellCssStyle = ""; $psacar_member->created_date->CellCssClass = "";
            $psacar_member->created_date->CellAttrs = array(); $psacar_member->created_date->ViewAttrs = array(); $psacar_member->created_date->EditAttrs = array();

            // modified_date
            $psacar_member->modified_date->CellCssStyle = ""; $psacar_member->modified_date->CellCssClass = "";
            $psacar_member->modified_date->CellAttrs = array(); $psacar_member->modified_date->ViewAttrs = array(); $psacar_member->modified_date->EditAttrs = array();

            // number_vehicle
            $psacar_member->number_vehicle->CellCssStyle = ""; $psacar_member->number_vehicle->CellCssClass = "";
            $psacar_member->number_vehicle->CellAttrs = array(); $psacar_member->number_vehicle->ViewAttrs = array(); $psacar_member->number_vehicle->EditAttrs = array();

            // car_type
            $psacar_member->car_type->CellCssStyle = ""; $psacar_member->car_type->CellCssClass = "";
            $psacar_member->car_type->CellAttrs = array(); $psacar_member->car_type->ViewAttrs = array(); $psacar_member->car_type->EditAttrs = array();

            // code
            $psacar_member->code->CellCssStyle = ""; $psacar_member->code->CellCssClass = "";
            $psacar_member->code->CellAttrs = array(); $psacar_member->code->ViewAttrs = array(); $psacar_member->code->EditAttrs = array();
            if ($psacar_member->RowType == EW_ROWTYPE_VIEW) { // View row

            } 
            elseif ($psacar_member->RowType == EW_ROWTYPE_ADD) { // Add row
                // location_id
                $psacar_member->location_id->EditCustomAttributes = "";
                        $sFilterWrk = "";
                $sSqlWrk = "SELECT `id`, `province`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_location`";
                $sWhereWrk = "";
                if ($sFilterWrk <> "") {
                        if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
                        $sWhereWrk .= "(" . $sFilterWrk . ")";
                }
                if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
                $rswrk = $conn->Execute($sSqlWrk);
                $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
                if ($rswrk) $rswrk->Close();
                array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
                $psacar_member->location_id->EditValue = $arwrk;

                // first_name
                $psacar_member->first_name->EditCustomAttributes = "";
                $psacar_member->first_name->EditValue = ew_HtmlEncode($psacar_member->first_name->CurrentValue);

                // last_name
                $psacar_member->last_name->EditCustomAttributes = "";
                $psacar_member->last_name->EditValue = ew_HtmlEncode($psacar_member->last_name->CurrentValue);

                // industry_id
                $psacar_member->industry_id->EditCustomAttributes = "";
                        $sFilterWrk = "";
                $sSqlWrk = "SELECT `id`, `industry`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_industry`";
                $sWhereWrk = "";
                if ($sFilterWrk <> "") {
                        if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
                        $sWhereWrk .= "(" . $sFilterWrk . ")";
                }
                if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
                $rswrk = $conn->Execute($sSqlWrk);
                $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
                if ($rswrk) $rswrk->Close();
                array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
                $psacar_member->industry_id->EditValue = $arwrk;

                // company
                $psacar_member->company->EditCustomAttributes = "";
                $psacar_member->company->EditValue = ew_HtmlEncode($psacar_member->company->CurrentValue);

                // company_phone_1
                $psacar_member->company_phone_1->EditCustomAttributes = "";
                $psacar_member->company_phone_1->EditValue = ew_HtmlEncode($psacar_member->company_phone_1->CurrentValue);

                // company_phone_2
                $psacar_member->company_phone_2->EditCustomAttributes = "";
                $psacar_member->company_phone_2->EditValue = ew_HtmlEncode($psacar_member->company_phone_2->CurrentValue);

                // name
                $psacar_member->name->EditCustomAttributes = "";
                $psacar_member->name->EditValue = ew_HtmlEncode($psacar_member->name->CurrentValue);

                // gender
                $psacar_member->gender->EditCustomAttributes = "";
                $arwrk = array();
                $arwrk[] = array("male", "Male");
                $arwrk[] = array("female", "Female");
                array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
                $psacar_member->gender->EditValue = $arwrk;

                // occupation_id
                $psacar_member->location_id->EditCustomAttributes = "";
                $sFilterWrk = "";
                $sSqlWrk = "SELECT `id`, `occupation`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_occupation`";
                $sWhereWrk = "";
                if ($sFilterWrk <> "") {
                    if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
                        $sWhereWrk .= "(" . $sFilterWrk . ")";
                }
                if ($sWhereWrk <> "") 
                    $sSqlWrk .= " WHERE " . $sWhereWrk;
                $rswrk = $conn->Execute($sSqlWrk);
                $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
                if ($rswrk) $rswrk->Close();
                array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
                $psacar_member->occupation_id->EditValue = $arwrk;

                // contact_phone_1
                $psacar_member->contact_phone_1->EditCustomAttributes = "";
                $psacar_member->contact_phone_1->EditValue = ew_HtmlEncode($psacar_member->contact_phone_1->CurrentValue);

                // contact_phone_2
                $psacar_member->contact_phone_2->EditCustomAttributes = "";
                $psacar_member->contact_phone_2->EditValue = ew_HtmlEncode($psacar_member->contact_phone_2->CurrentValue);

                // address
                $psacar_member->address->EditCustomAttributes = "";
                $psacar_member->address->EditValue = ew_HtmlEncode($psacar_member->address->CurrentValue);

                // email
                $psacar_member->zemail->EditCustomAttributes = "";
                $psacar_member->zemail->EditValue = ew_HtmlEncode($psacar_member->zemail->CurrentValue);

                // website
                $psacar_member->website->EditCustomAttributes = "";
                $psacar_member->website->EditValue = ew_HtmlEncode($psacar_member->website->CurrentValue);

                // password
                $psacar_member->password->EditCustomAttributes = "";
                $psacar_member->password->EditValue = ew_HtmlEncode($psacar_member->password->CurrentValue);

                // number_vehicle
                $psacar_member->number_vehicle->EditCustomAttributes = "";
                $arwrk = array();
                for($counter = 1; $counter <= 100; $counter++) {
                    $arwrk[] = array($counter, $counter);
                }
                array_unshift($arwrk, array("0", $Language->Phrase("PleaseSelect")));
                $psacar_member->number_vehicle->EditValue = $arwrk;

                // type_id
                $psacar_member->type_id->EditCustomAttributes = "";
                $sFilterWrk = "";
                $sSqlWrk = "SELECT `id`, `member_type`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_member_type`";
                $sWhereWrk = "";
                if ($sFilterWrk <> "") {
                    if ($sWhereWrk <> "") 
                        $sWhereWrk .= " AND ";
                    $sWhereWrk .= "(" . $sFilterWrk . ")";
                }
                if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
                $rswrk = $conn->Execute($sSqlWrk);
                $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
                if ($rswrk) $rswrk->Close();
                array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
                $psacar_member->type_id->EditValue = $arwrk;                   

                // service
                $psacar_member->service->EditCustomAttributes = "";
                        $sFilterWrk = "";
                $sSqlWrk = "SELECT `id`, `member_id`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_member_service`";
                $sWhereWrk = "";
                if ($sFilterWrk <> "") {
                        if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
                        $sWhereWrk .= "(" . $sFilterWrk . ")";
                }
                if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
                $rswrk = $conn->Execute($sSqlWrk);
                $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
                if ($rswrk) $rswrk->Close();
                $psacar_member->service->EditValue = $arwrk;

                // description
                $psacar_member->description->EditCustomAttributes = "";
                $psacar_member->description->EditValue = ew_HtmlEncode($psacar_member->description->CurrentValue);

                // is_active
                $psacar_member->is_active->EditCustomAttributes = "";
                $arwrk = array();
                $arwrk[] = array("1", "Active");
                $psacar_member->is_active->EditValue = $arwrk;

                // created_date
                $psacar_member->created_date->EditCustomAttributes = "";
                $psacar_member->created_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($psacar_member->created_date->CurrentValue, 5));

                // modified_date
                $psacar_member->modified_date->EditCustomAttributes = "";
                $psacar_member->modified_date->EditValue = ew_HtmlEncode(ew_FormatDateTime($psacar_member->modified_date->CurrentValue, 5));

                // number_vehicle
                $psacar_member->number_vehicle->EditCustomAttributes = "";
                //$psacar_member->number_vehicle->EditValue = ew_HtmlEncode($psacar_member->number_vehicle->CurrentValue);

                // car_type
                $psacar_member->car_type->EditCustomAttributes = "";
                $psacar_member->car_type->EditCustomAttributes = "";
                        $sFilterWrk = "";
                $sSqlWrk = "SELECT `id`, `name`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `psacar_car_type`";
                $sWhereWrk = "";
                if ($sFilterWrk <> "") {
                        if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
                        $sWhereWrk .= "(" . $sFilterWrk . ")";
                }
                if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
                $rswrk = $conn->Execute($sSqlWrk);
                $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
                if ($rswrk) $rswrk->Close();
                $psacar_member->car_type->EditValue = $arwrk;

                // code
                $psacar_member->code->EditCustomAttributes = "";
                $psacar_member->code->EditValue = ew_HtmlEncode($psacar_member->code->CurrentValue);
            }

            // Call Row Rendered event
            if ($psacar_member->RowType <> EW_ROWTYPE_AGGREGATEINIT)
                $psacar_member->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $psacar_member;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!is_null($psacar_member->first_name->FormValue) && $psacar_member->first_name->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_member->first_name->FldCaption();
		}
		if (!is_null($psacar_member->last_name->FormValue) && $psacar_member->last_name->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_member->last_name->FldCaption();
		}
		if (!ew_CheckInteger($psacar_member->occupation_id->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_member->occupation_id->FldErrMsg();
		}
		if (!is_null($psacar_member->password->FormValue) && $psacar_member->password->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_member->password->FldCaption();
		}
		if (!is_null($psacar_member->type_id->FormValue) && $psacar_member->type_id->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $psacar_member->type_id->FldCaption();
		}
		if (!ew_CheckDate($psacar_member->created_date->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_member->created_date->FldErrMsg();
		}
		if (!ew_CheckDate($psacar_member->modified_date->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_member->modified_date->FldErrMsg();
		}
		if (!ew_CheckInteger($psacar_member->number_vehicle->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $psacar_member->number_vehicle->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Add record
	function AddRow() {
            global $conn, $Language, $Security, $psacar_member;
            $rsnew = array();

            // location_id
            $psacar_member->location_id->SetDbValueDef($rsnew, $psacar_member->location_id->CurrentValue, NULL, FALSE);

            // first_name
            $psacar_member->first_name->SetDbValueDef($rsnew, $psacar_member->first_name->CurrentValue, "", FALSE);

            // last_name
            $psacar_member->last_name->SetDbValueDef($rsnew, $psacar_member->last_name->CurrentValue, "", FALSE);

            // industry_id
            $psacar_member->industry_id->SetDbValueDef($rsnew, $psacar_member->industry_id->CurrentValue, NULL, FALSE);

            // company
            $psacar_member->company->SetDbValueDef($rsnew, $psacar_member->company->CurrentValue, NULL, FALSE);

            // company_phone_1
            $psacar_member->company_phone_1->SetDbValueDef($rsnew, $psacar_member->company_phone_1->CurrentValue, NULL, FALSE);

            // company_phone_2
            $psacar_member->company_phone_2->SetDbValueDef($rsnew, $psacar_member->company_phone_2->CurrentValue, NULL, FALSE);

            // name
            $psacar_member->name->SetDbValueDef($rsnew, $psacar_member->name->CurrentValue, NULL, FALSE);

            // gender
            $psacar_member->gender->SetDbValueDef($rsnew, $psacar_member->gender->CurrentValue, NULL, FALSE);

            // occupation_id
            $psacar_member->occupation_id->SetDbValueDef($rsnew, $psacar_member->occupation_id->CurrentValue, NULL, FALSE);

            // contact_phone_1
            $psacar_member->contact_phone_1->SetDbValueDef($rsnew, $psacar_member->contact_phone_1->CurrentValue, NULL, FALSE);

            // contact_phone_2
            $psacar_member->contact_phone_2->SetDbValueDef($rsnew, $psacar_member->contact_phone_2->CurrentValue, NULL, FALSE);

            // address
            $psacar_member->address->SetDbValueDef($rsnew, $psacar_member->address->CurrentValue, NULL, FALSE);

            // email
            $psacar_member->zemail->SetDbValueDef($rsnew, $psacar_member->zemail->CurrentValue, NULL, FALSE);

            // website
            $psacar_member->website->SetDbValueDef($rsnew, $psacar_member->website->CurrentValue, NULL, FALSE);

            // password
            $psacar_member->password->SetDbValueDef($rsnew, $psacar_member->password->CurrentValue, "", FALSE);

            // type_id
            $psacar_member->type_id->SetDbValueDef($rsnew, $psacar_member->type_id->CurrentValue, 0, FALSE);

            // service
            $psacar_member->service->SetDbValueDef($rsnew, $psacar_member->service->CurrentValue, NULL, FALSE);

            // description
            $psacar_member->description->SetDbValueDef($rsnew, $psacar_member->description->CurrentValue, NULL, FALSE);

            // is_active
            $psacar_member->is_active->SetDbValueDef($rsnew, $psacar_member->is_active->CurrentValue, 0, TRUE);

            // created_date
            $psacar_member->created_date->SetDbValueDef($rsnew, ew_UnFormatDateTime($psacar_member->created_date->CurrentValue, 5, FALSE), NULL);

            // modified_date
            $psacar_member->modified_date->SetDbValueDef($rsnew, ew_UnFormatDateTime($psacar_member->modified_date->CurrentValue, 5, FALSE), NULL);

            // number_vehicle
            $psacar_member->number_vehicle->SetDbValueDef($rsnew, $psacar_member->number_vehicle->CurrentValue, NULL, TRUE);

            // car_type
            $psacar_member->car_type->SetDbValueDef($rsnew, $psacar_member->car_type->CurrentValue, NULL, FALSE);

            // code
            $psacar_member->code->SetDbValueDef($rsnew, $psacar_member->code->CurrentValue, NULL, FALSE);

            // Call Row Inserting event
            $bInsertRow = $psacar_member->Row_Inserting($rsnew);
            if ($bInsertRow) {
                $conn->raiseErrorFn = 'ew_ErrorFn';
                $AddRow = $conn->Execute($psacar_member->InsertSQL($rsnew));
                $conn->raiseErrorFn = '';
            } else {
                if ($psacar_member->CancelMessage <> "") {
                        $this->setMessage($psacar_member->CancelMessage);
                        $psacar_member->CancelMessage = "";
                } else {
                        $this->setMessage($Language->Phrase("InsertCancelled"));
                }
                $AddRow = FALSE;
            }
            
            if ($AddRow) {
                $psacar_member->id->setDbValue($conn->Insert_ID());
                $rsnew['id'] = $psacar_member->id->DbValue;

                // Call Row Inserted event
                $psacar_member->Row_Inserted($rsnew);

                //Reference number
                $sFilterWrk = "id = " . $psacar_member->type_id->CurrentValue;
                $sSqlWrk = "SELECT `short_code` FROM `psacar_member_type`";
                $sWhereWrk = "";
                if ($sFilterWrk <> "") {
                    if ($sWhereWrk <> "") 
                        $sWhereWrk .= " AND ";
                    $sWhereWrk .= "(" . $sFilterWrk . ")";
                }
                if ($sWhereWrk <> "") 
                    $sSqlWrk .= " WHERE " . $sWhereWrk;

                $rswrk = $conn->Execute($sSqlWrk);
                $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
                if ($rswrk) 
                    $rswrk->Close();

                $member_code = '';
                foreach($arwrk as $type)
                    $member_code = $type[0];

                $keys = array_merge(range(0, 9), range('a', 'z', range('A', 'Z')));
                for($counter = 0; $counter < 3; $counter++) {
                    $key .= $keys[array_rand($keys)];
                }
                $member_code .= 
                    substr('00000' . $psacar_member->id->DbValue, -5) . 
                    $key;                    
                $psacar_member->code->SetDbValueDef($rsnew, $member_code, "", FALSE);

                $psacar_member->CurrentFilter = "Id = " . $psacar_member->id->DbValue;
                $conn->raiseErrorFn = 'ew_ErrorFn';
                $EditRow = $conn->Execute($psacar_member->UpdateSQL($rsnew));
                $conn->raiseErrorFn = '';
            }
            return $AddRow;
	}

		// Page Load event
	function Page_Load() {

	    //echo "Page Load";  
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
